#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 100010;
using ll = long long;
ll s[N], res[N];
int n, k;
int main()
{
    cin >> n >> k;
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> s[i];
        s[i] = (s[i - 1] + s[i]) % k;
        ans += res[s[i]];
        res[s[i]]++;
    }
    cout << ans + res[0] << endl;
    return 0;
}